﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;

namespace _430GroupProject
{
    /// <summary>
    /// Launch point for the server.
    /// </summary>
    class Program
    {
        /// <summary>
        /// Creates and hosts a service for the Employee Management System.
        /// </summary>
        static void Main(string[] args)
        {
            Uri baseAddress = new Uri("http://"+"localhost"+/*64.113.91.69*/":8000/nspremo");
            ServiceHost selfHost = new ServiceHost(typeof(EMSServices), baseAddress);

            try
            {
                BasicHttpBinding myBinding = new BasicHttpBinding();
                myBinding.MaxReceivedMessageSize = int.MaxValue;
                selfHost.AddServiceEndpoint(
                    typeof(IEMSServices),
                    myBinding,
                    "Service");

                selfHost.Open();
                Console.WriteLine("The service is ready, hosted on: " + selfHost.BaseAddresses[0]);
                Console.WriteLine("Press <ENTER> to terminate service.");
                Console.WriteLine();
                Console.ReadLine();
                selfHost.Close();
            }
            //Prints out error is problem starting the service.
            catch (CommunicationException ce)
            {
                Console.WriteLine("An exception occurred: {0}", ce.Message);
                Console.ReadLine();
                selfHost.Abort();
            }
        }
    }
}
